package sc.display;

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;

import sc.writable.IntermediateData;

/**
 * Shows detailed informations about a stock.
 * 
 * @author Quentin Rossé
 *
 */
@SuppressWarnings("serial")
public class DetailFrame extends JFrame{

	private static final int DEFAULT_SIZE_X = 800;
	
	private static final int DEFAULT_SIZE_Y = 600;
	
	private JTable table;
	
	public DetailFrame(String stock, Object[][] data){	
		setTitle(stock);
        setSize(DEFAULT_SIZE_X, DEFAULT_SIZE_Y);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setLayout(new GridLayout(1, 0));
        
		table = new JTable(data, IntermediateData.getArrayColumnNames());
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        JScrollPane scrollPane = new JScrollPane(table);
        add(scrollPane);
        
        setVisible(true);
	}
}
